<template>
  <view class="navbar" :style="{ paddingTop: safeAreaInsetsTop + 'px' }">
    <!-- logo文字 -->
    <view class="logo">
      <image class="logo-image" src="@/static/images/logo.png"></image>
      <text class="logo-text">宠爱 · 陪伴 · 伙伴</text>
    </view>
    <!-- 搜索条 -->
    <view class="search" @click="goToReviewPage">
      <text class="icon-search">搜索宠物</text>
      <text class="icon-scan"></text>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      safeAreaInsetsTop: 0 // 初始化安全区域顶部 insets 的值
    };
  },
  mounted() {
    // 在 mounted 生命周期钩子中获取安全区距离
    const { safeAreaInsets } = uni.getSystemInfoSync();
    this.safeAreaInsetsTop = safeAreaInsets.top; // 直接赋值给 safeAreaInsetsTop
  },
  methods :{
	  goToReviewPage() {
	          uni.navigateTo({
	              url: '/pages/search/search' // 确保页面路径正确
	          });
	      },
  }
};
</script>


<style lang="scss">
/* 自定义导航条 */
.navbar {
  // background-image: url('@/static/images/navigator_bg.png');
  background-color: #fdd300;
  background-size: cover;
  position: relative;
  display: flex;
  flex-direction: column;
  padding-top: 20px;
  .logo {
    display: flex;
    align-items: center;
    height: 64rpx;
    padding-left: 30rpx;
    padding-top: 20rpx;
    .logo-image {
      width: 166rpx;
      height: 39rpx;
    }
    .logo-text {
      flex: 1;
      line-height: 28rpx;
      color: #fff;
      margin: 2rpx 0 0 20rpx;
      padding-left: 20rpx;
      border-left: 1rpx solid #fff;
      font-size: 26rpx;
    }
  }
  .search {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10rpx 0 26rpx;
    height: 64rpx;
    margin: 16rpx 20rpx;
    color: #fff;
    font-size: 28rpx;
    border-radius: 32rpx;
    background-color: rgba(255, 255, 255, 0.5);
  }
  .icon-search {
    &::before {
      margin-right: 10rpx;
    }
  }
  .icon-scan {
    font-size: 30rpx;
    padding: 15rpx;
  }
}
</style>
